package com.ruoyi.teaching.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teaching.mapper.YaStageTaskSubmitMapper;
import com.ruoyi.teaching.domain.YaStageTaskSubmit;
import com.ruoyi.teaching.service.IYaStageTaskSubmitService;

/**
 * 学生任务提交情况Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-12
 */
@Service
public class YaStageTaskSubmitServiceImpl implements IYaStageTaskSubmitService
{
    @Autowired
    private YaStageTaskSubmitMapper yaStageTaskSubmitMapper;

    /**
     * 查询学生任务提交情况
     *
     * @param taskId 学生任务提交情况主键
     * @return 学生任务提交情况
     */
    @Override
    public YaStageTaskSubmit selectYaStageTaskSubmitByTaskId(Long taskId)
    {
        return yaStageTaskSubmitMapper.selectYaStageTaskSubmitByTaskId(taskId);
    }

    /**
     * 查询学生任务提交情况列表
     *
     * @param yaStageTaskSubmit 学生任务提交情况
     * @return 学生任务提交情况
     */
    @Override
    public List<YaStageTaskSubmit> selectYaStageTaskSubmitList(YaStageTaskSubmit yaStageTaskSubmit)
    {
        return yaStageTaskSubmitMapper.selectYaStageTaskSubmitList(yaStageTaskSubmit);
    }

    /**
     * 新增学生任务提交情况
     *
     * @param yaStageTaskSubmit 学生任务提交情况
     * @return 结果
     */
    @Override
    public int insertYaStageTaskSubmit(YaStageTaskSubmit yaStageTaskSubmit)
    {
        yaStageTaskSubmit.setCreateTime(DateUtils.getNowDate());
        return yaStageTaskSubmitMapper.insertYaStageTaskSubmit(yaStageTaskSubmit);
    }

    /**
     * 修改学生任务提交情况
     *
     * @param yaStageTaskSubmit 学生任务提交情况
     * @return 结果
     */
    @Override
    public int updateYaStageTaskSubmit(YaStageTaskSubmit yaStageTaskSubmit)
    {
        yaStageTaskSubmit.setUpdateTime(DateUtils.getNowDate());
        return yaStageTaskSubmitMapper.updateYaStageTaskSubmit(yaStageTaskSubmit);
    }

    /**
     * 批量删除学生任务提交情况
     *
     * @param taskIds 需要删除的学生任务提交情况主键
     * @return 结果
     */
    @Override
    public int deleteYaStageTaskSubmitByTaskIds(Long[] taskIds)
    {
        return yaStageTaskSubmitMapper.deleteYaStageTaskSubmitByTaskIds(taskIds);
    }

    /**
     * 删除学生任务提交情况信息
     *
     * @param taskId 学生任务提交情况主键
     * @return 结果
     */
    @Override
    public int deleteYaStageTaskSubmitByTaskId(Long taskId)
    {
        return yaStageTaskSubmitMapper.deleteYaStageTaskSubmitByTaskId(taskId);
    }

    @Override
    public void submit(YaStageTaskSubmit yaStageTaskSubmit) {
        yaStageTaskSubmit.setStudentId(SecurityUtils.getUserId());
        yaStageTaskSubmit.setStatus("1");
        yaStageTaskSubmit.setCreateTime(new Date());
        yaStageTaskSubmit.setCreateBy(SecurityUtils.getUsername());
        yaStageTaskSubmitMapper.insertYaStageTaskSubmit(yaStageTaskSubmit);
    }
}
